package com.google.code.stalkernet.entry;

import java.util.Arrays;

/**
 * Abstract base class for implementations of {@link EntryID} interface.
 *
 * @author Mikhail Vladimirov
 */
public abstract class AbstractEntryID implements EntryID
{
    /**
     * {@inheritDoc}
     */
    @Override
    public int hashCode ()
    {
        return Arrays.hashCode (getBytes ());
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean equals (Object obj)
    {
        if (obj instanceof EntryID)
            return Arrays.equals (getBytes (), ((EntryID)obj).getBytes ());
        else return false;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String toString ()
    {
        return EntryUtils.formatEntryID (this);
    }
}
